//
//  MainVC_ContactBook_ButtonView.m
//  liBaQiang
//
//  Created by 奇林刘 on 2018/10/15.
//  Copyright © 2018年 liu. All rights reserved.
//

#import "MainVC_ContactBook_ButtonView.h"

@interface MainVC_ContactBook_ButtonView ()

@property (nonatomic, strong) UIView *lineTop;
@property (nonatomic, strong) UIImageView *leftLogoImageView;
@property (nonatomic, strong) UILabel *leftTitleLabel;
@property (nonatomic, strong) UIImageView *rightLogoImageView;
@property (nonatomic, strong) UILabel *rightTitleLabel;
@property (nonatomic, strong) UIView *lineBottom;

@end

@implementation MainVC_ContactBook_ButtonView {
    CGFloat _height;
    NSString *_rightTitle;
    NSString *_rightLogo;
    NSString *_leftTitle;
    NSString *_leftLogo;
    UIFont *_leftTitleFont;
    CGFloat _leftLogoWidth;
    CGFloat _leftLogoHeight;
}

#pragma mark - lifeCycle
- (instancetype)initWithHeight:(CGFloat)height
                    rightTitle:(NSString *)rightTitle
                rightLogoImage:(NSString *)rightLogo
                     leftTitle:(NSString *)leftTitle
                 leftLogoImage:(NSString *)leftLogo
                 leftTitleFont:(UIFont *)leftTitleFont
                 leftLogoWidth:(CGFloat)leftLogoWidth
                leftLogoHeight:(CGFloat)leftLogoHeight {
    _height = height;
    _rightTitle = rightTitle;
    _rightLogo = rightLogo;
    _leftTitle = leftTitle;
    _leftLogo = leftLogo;
    _leftTitleFont = leftTitleFont;
    _leftLogoWidth = leftLogoWidth;
    _leftLogoHeight = leftLogoHeight;
    self = [super init];
    return self;
}

- (void)configSelf {
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(WINDOW_WIDTH));
        make.height.equalTo(@(self->_height));
    }];
    self.fp_backgroundColor(HexadecimalColor(@"#FFFFFF"));
}

- (void)allocateComponents {
    [self allocateLineTop];
    [self allocateLeftLogoImageView];
    [self allocateLeftTitleLabel];
    [self allocateRightTitleLabel];
    [self allocateRightLogoImageView];
    [self allocateLineBottom];
    [self allocateRightButton];
    [self allocateLeftButton];
}

- (void)configComponents {
    self.lineTop.fp_backgroundColor(HexadecimalColor(@"#EBEBEB"));
    [self.leftLogoImageView setImage:[UIImage imageNamed:_leftLogo]];
    self.leftTitleLabel.fp_font(_leftTitleFont).fp_text(_leftTitle);
    self.rightTitleLabel.fp_font(RPXFont(14)).fp_textColor(HexadecimalColor(@"#2D5898")).fp_text(_rightTitle);
    [self.rightLogoImageView setImage:[UIImage imageNamed:_rightLogo]];
    self.rightLogoImageView.fp_contentMode(UIViewContentModeScaleAspectFit);
    self.lineBottom.fp_backgroundColor(HexadecimalColor(@"#EBEBEB"));
}

#pragma mark - usedMethods
- (void)allocateLineTop {
    self.fp_addSubview(self.lineTop=[[UIView alloc]init]);
    [self.lineTop mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self);
        make.height.equalTo(@(0.5));
    }];
}

- (void)allocateLeftLogoImageView {
    self.fp_addSubview(self.leftLogoImageView=[[UIImageView alloc]init]);
    [self.leftLogoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(self->_leftLogoWidth));
        make.height.equalTo(@(self->_leftLogoHeight));
        make.centerY.equalTo(self);
        make.centerX.equalTo(self.mas_left).offset(RPX(35));
    }];
}

- (void)allocateLeftTitleLabel {
    self.fp_addSubview(self.leftTitleLabel=[[UILabel alloc]init]);
    [self.leftTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(RPX(66));
    }];
}

- (void)allocateRightTitleLabel {
    self.fp_addSubview(self.rightTitleLabel=[[UILabel alloc]init]);
    [self.rightTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(self).offset(RPX(-15));
    }];
}

- (void)allocateRightLogoImageView {
    self.fp_addSubview(self.rightLogoImageView=[[UIImageView alloc]init]);
    [self.rightLogoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(self).offset(RPX(-54));
        make.height.equalTo(self);
        make.width.equalTo(@(RPX(18)));
    }];
}

- (void)allocateLineBottom {
    self.fp_addSubview(self.lineBottom=[[UIView alloc]init]);
    [self.lineBottom mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.equalTo(self);
        make.height.equalTo(@(0.5));
    }];
}

- (void)allocateRightButton {
    self.fp_addSubview(self.rightButton=[[BaseButton alloc]init]);
    [self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.bottom.equalTo(self);
        make.left.equalTo(self.rightLogoImageView).offset(RPX(-15));
    }];
}

- (void)allocateLeftButton {
    self.fp_addSubview(self.leftButton=[[BaseButton alloc]init]);
    [self.leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.equalTo(self);
        make.right.equalTo(self.rightButton.mas_left);
    }];
}



@end
